import 'package:extended_tabs/extended_tabs.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import '../../../common/app_colors.dart';
import '../../../common/app_text_style.dart';
import '../../../widget/indicator/material_indicator.dart';
import 'tab_bar_movies_logic.dart';

class TabBarMoviesPage extends StatefulWidget {
  const TabBarMoviesPage({Key? key}) : super(key: key);

  @override
  State<TabBarMoviesPage> createState() => TabBarMoviesPageState();

}

class TabBarMoviesPageState extends State<TabBarMoviesPage> with TickerProviderStateMixin{

  final logic = Get.put(TabBarMoviesLogic());
  final state = Get.find<TabBarMoviesLogic>().state;

  @override
  void initState() {
    super.initState();
    state.tabController = TabController(length: state.tabs.length, vsync: this);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.grey,
       body:Directionality(
           textDirection: TextDirection.ltr,
           child: Column(
             children: [
               Container(
                   margin: EdgeInsets.only(top: 8.w),
                   decoration: BoxDecoration(
                     // 圆角半径
                     borderRadius: BorderRadius.all(Radius.circular(18.w)),
                     //边框线宽、颜色
                     border: Border.all(width: 1.w, color: AppColors.colorFFF7F8FA),
                   ),
                   width: 196.w,
                   height: 36.w,
                   child: tabBar()),
               Expanded(
                   child: ExtendedTabBarView(
                       shouldIgnorePointerWhenScrolling: false,
                       controller: state.tabController,
                       children: [
                         Container(),Container(),Container()
                       ]))
             ],
           ))
    );
  }

  Widget tabBar() {
    return TabBar(
        tabs: state.tabs,
        controller: state.tabController,
        labelStyle: TS_FFE80054_16_w5,
        labelColor:  AppColors.contentColorPink,
        unselectedLabelStyle: TS_FFE80054_16_w4,
        unselectedLabelColor: AppColors.colorFFF7F8FA,
        padding:  EdgeInsets.only(top: 2.w),
        indicator:  UIMaterialIndicator(
            height: 28.w,
            color: AppColors.colorFFF7F8FA,
            topLeftRadius: 14.w,
            topRightRadius: 14.w,
            bottomLeftRadius: 14.w,
            bottomRightRadius: 14.w,
            horizontalPadding: 4.w,
            tabPosition: TabPosition.center,
            tabOffsetValue: -1.w));
  }
}
